/*
    Copyright 2015 <copyright holder> <email>

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
*/


#ifndef LCD_DISPLAY_H
#define LCD_DISPLAY_H
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <linux/types.h>
#include <linux/videodev2.h>
#include <malloc.h>
#include <math.h>
#include <sys/mman.h>
#include <errno.h>
#include <assert.h>
#include <string.h>
#include <sys/time.h>
#include <linux/fb.h>
#include <time.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class lcd_display
{
private:
	struct fb_var_screeninfo vinfo;  
	struct fb_fix_screeninfo finfo;    //lcd的信息
	int lcd_buf_size;                  //lcd的数据显示存储区大小  
	char *fb_lcd_buf;                  //显示存储区的指针
	int lcd_fd; 
	string lcd_device_file;
public:
	lcd_display(){}
	lcd_display(string device_file);
	virtual ~lcd_display();

private:
	int clip(int value, int min, int max);
	void lcd_open();
	void lcd_close();
public:
	void lcd_init();
	void lcd_show(int w,int h,void* addr);
};

#endif // LCD_DISPLAY_H
